package hpu.bitenergy.servlet;

import hpu.bitenergy.Factory.Factory;
import hpu.bitenergy.IFactory.IFactory;
import hpu.bitenergy.List.GetList;
import hpu.bitenergy.util.QueryHelper;
import hpu.bitenergy.util.StringHelper;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mongodb.DBObject;

public class intelligenceservlet extends HttpServlet {
//情报

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		String expert_name=new String(request.getParameter("expert_name").getBytes("ISO_8859-1"), "UTF-8");		
		System.out.println(expert_name);
	
		IFactory fa=Factory.GetIFactory("I");
		GetList li=fa.GetListInstance();
		List<DBObject> list=li.getQueryList(QueryHelper.expert_name(expert_name.trim()));
		 
		System.out.println(list);
		if(list.size()!=0){
			request.setAttribute("list", list);
			request.getRequestDispatcher("/intelligence.jsp").forward(request, response);
		}else
		{	list=null;
			request.setAttribute("list", list);
			request.getRequestDispatcher("/intelligence.jsp").forward(request, response);
		}
		
	}

}
